package fuzzylizard.teamdocs.domain;

import java.io.Serializable;

/**
 * wraps a single edition of a file uploaded by a user
 *
 */
public class Version extends PersistedObject implements Serializable {

    /**
     * The version of the associated document
     */
    private int version;

    /**
     * Creates a new version of a document
     * @return New Version
     */
    public static Version newVersion() {
        return new Version();
    }

    /**
     * Version number
     */
    private Version() {
        version = 1;
    }

    
    private Version(int v) {
        version += v;
    }

    public Version nextVersion() {
        return new Version(version);
    }
    
    @Override
    public String toString() {
        return "" + version;
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 37;
        result = prime * result + version;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final Version other = (Version) obj;
        if (version != other.version)
            return false;
        return true;
    }
}
